gtkcssimagelinearprivate.h \
gtkcssimageprivate.h \
gtkcssimageurlprivate.h \
+ gtkcssimagevalueprivate.h \
gtkcssimagewin32private.h \
gtkcssinheritvalueprivate.h \
gtkcssinitialvalueprivate.h \
gtkcssimagegradient.c \
gtkcssimagelinear.c \
gtkcssimageurl.c \
+ gtkcssimagevalue.c \
gtkcssimagewin32.c \
gtkcssinheritvalue.c \
gtkcssinitialvalue.c \
#include <math.h>
#include "gtkborderimageprivate.h"
+#include "gtkcssimagevalueprivate.h"
#include "gtkstylepropertiesprivate.h"
#include "gtkthemingengineprivate.h"
{
GtkBorder *width;
- image->source = _gtk_css_value_get_object (_gtk_theming_engine_peek_property (engine, "border-image-source"));
+ image->source = _gtk_css_image_value_get_image (_gtk_theming_engine_peek_property (engine, "border-image-source"));
if (image->source == NULL)
return FALSE;
--- /dev/null
+/* GTK - The GIMP Toolkit
+ * Copyright (C) 2011 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "config.h"
+
+#include "gtkcssimagevalueprivate.h"
+
+#include "gtkstylepropertyprivate.h"
+
+struct _GtkCssValue {
+ GTK_CSS_VALUE_BASE
+ GtkCssImage *image;
+};
+
+static void
+gtk_css_value_image_free (GtkCssValue *value)
+{
+ g_object_unref (value->image);
+ g_slice_free (GtkCssValue, value);
+}
+
+static gboolean
+gtk_css_value_image_equal (const GtkCssValue *value1,
+ const GtkCssValue *value2)
+{
+ return value1->image == value2->image;
+}
+
+static void
+gtk_css_value_image_print (const GtkCssValue *value,
+ GString *string)
+{
+ if (value->image)
+ _gtk_css_image_print (value->image, string);
+ else
+ g_string_append (string, "none");
+}
+
+static const GtkCssValueClass GTK_CSS_VALUE_IMAGE = {
+ gtk_css_value_image_free,
+ gtk_css_value_image_equal,
+ gtk_css_value_image_print
+};
+
+GtkCssValue *
+_gtk_css_image_value_new (GtkCssImage *image)
+{
+ static GtkCssValue none_singleton = { >K_CSS_VALUE_IMAGE, 1, NULL };
+ GtkCssValue *value;
+
+ if (image == NULL)
+ return _gtk_css_value_ref (&none_singleton);
+
+ value = _gtk_css_value_new (GtkCssValue, >K_CSS_VALUE_IMAGE);
+ value->image = image;
+
+ return value;
+}
+
+GtkCssImage *
+_gtk_css_image_value_get_image (const GtkCssValue *value)
+{
+ g_return_val_if_fail (value->class == >K_CSS_VALUE_IMAGE, NULL);
+
+ return value->image;
+}
+
--- /dev/null
+/*
+ * Copyright © 2012 Red Hat Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Authors: Alexander Larsson <alexl@gnome.org>
+ */
+
+#ifndef __GTK_CSS_IMAGE_VALUE_PRIVATE_H__
+#define __GTK_CSS_IMAGE_VALUE_PRIVATE_H__
+
+#include "gtkcssimageprivate.h"
+#include "gtkcssvalueprivate.h"
+
+G_BEGIN_DECLS
+
+GtkCssValue * _gtk_css_image_value_new (GtkCssImage *image);
+
+GtkCssImage * _gtk_css_image_value_get_image (const GtkCssValue *image);
+
+
+G_END_DECLS
+
+#endif /* __GTK_CSS_IMAGE_VALUE_PRIVATE_H__ */
#include "gtkcssenumvalueprivate.h"
#include "gtkcssimageprivate.h"
+#include "gtkcssimagevalueprivate.h"
#include "gtkcssnumbervalueprivate.h"
#include "gtkcssstylefuncsprivate.h"
#include "gtkcsstypesprivate.h"
if (!image)
return FALSE;
}
- values[0] = _gtk_css_value_new_take_image (image);
+ values[0] = _gtk_css_image_value_new (image);
if (value_is_done_parsing (parser))
return TRUE;
return FALSE;
}
- values[0] = _gtk_css_value_new_take_image (image);
+ values[0] = _gtk_css_image_value_new (image);
}
else if (values[1] == NULL &&
_gtk_css_parser_try_enum (parser, GTK_TYPE_CSS_BACKGROUND_REPEAT, &enum_value))
#include "gtkbindings.h"
#include "gtkcssimagegradientprivate.h"
#include "gtkcssimageprivate.h"
-#include "gtkcssimageprivate.h"
+#include "gtkcssimagevalueprivate.h"
#include "gtkcssenumvalueprivate.h"
#include "gtkcssnumbervalueprivate.h"
#include "gtkcssrgbavalueprivate.h"
return FALSE;
}
- return _gtk_css_value_new_take_image (image);
-}
-
-static void
-css_image_value_print (GtkCssStyleProperty *property,
- const GtkCssValue *value,
- GString *string)
-{
- GtkCssImage *image = _gtk_css_value_get_image (value);
-
- if (image)
- _gtk_css_image_print (image, string);
- else
- g_string_append (string, "none");
+ return _gtk_css_image_value_new (image);
}
static GtkCssValue *
{
GtkCssImage *image, *computed;
- image = _gtk_css_value_get_image (specified);
+ image = _gtk_css_image_value_get_image (specified);
if (image == NULL)
return _gtk_css_value_ref (specified);
return _gtk_css_value_ref (specified);
}
- return _gtk_css_value_new_take_image (computed);
+ return _gtk_css_image_value_new (computed);
}
static void
const GtkCssValue *css_value,
GValue *value)
{
- GtkCssImage *image = _gtk_css_value_get_image (css_value);
+ GtkCssImage *image = _gtk_css_image_value_get_image (css_value);
cairo_pattern_t *pattern;
cairo_surface_t *surface;
cairo_matrix_t matrix;
const GValue *value)
{
g_warning ("FIXME: assigning images is not implemented");
- return _gtk_css_value_new_take_image (NULL);
+ return _gtk_css_image_value_new (NULL);
}
static GtkCssValue *
CAIRO_GOBJECT_TYPE_PATTERN,
0,
css_image_value_parse,
- css_image_value_print,
+ NULL,
css_image_value_compute,
css_image_value_query,
css_image_value_assign,
NULL,
- _gtk_css_value_new_take_image (NULL));
+ _gtk_css_image_value_new (NULL));
gtk_css_style_property_register ("border-image-source",
CAIRO_GOBJECT_TYPE_PATTERN,
0,
css_image_value_parse,
- css_image_value_print,
+ NULL,
css_image_value_compute,
css_image_value_query,
css_image_value_assign,
NULL,
- _gtk_css_value_new_take_image (NULL));
+ _gtk_css_image_value_new (NULL));
gtk_css_style_property_register ("border-image-repeat",
GTK_TYPE_CSS_BORDER_IMAGE_REPEAT,
0,
return value;
}
-GtkCssValue *
-_gtk_css_value_new_take_image (GtkCssImage *v)
-{
- GtkCssValue *value;
-
- value = gtk_css_value_new (GTK_TYPE_CSS_IMAGE);
- value->u.ptr = v;
-
- return value;
-}
-
GtkCssValue *
_gtk_css_value_new_from_theming_engine (GtkThemingEngine *v)
{
return value->u.ptr;
}
-GtkCssImage *
-_gtk_css_value_get_image (const GtkCssValue *value)
-{
- g_return_val_if_fail (_gtk_css_value_holds (value, GTK_TYPE_CSS_IMAGE), NULL);
- return value->u.ptr;
-}
-
GtkBorderStyle
_gtk_css_value_get_border_style (const GtkCssValue *value)
{
#include <glib-object.h>
#include "gtkcsstypesprivate.h"
#include "gtksymboliccolor.h"
-#include "gtkcssimageprivate.h"
#include "gtkthemingengine.h"
G_BEGIN_DECLS
GtkCssValue *_gtk_css_value_new_from_color (const GdkColor *v);
GtkCssValue *_gtk_css_value_new_take_symbolic_color (GtkSymbolicColor *v);
GtkCssValue *_gtk_css_value_new_take_pattern (cairo_pattern_t *v);
-GtkCssValue *_gtk_css_value_new_take_image (GtkCssImage *v);
GtkCssValue *_gtk_css_value_new_from_theming_engine (GtkThemingEngine *v);
GtkCssValue *_gtk_css_value_new_take_binding_sets (GPtrArray *array);
GtkCssValue *_gtk_css_value_new_from_background_size (const GtkCssBackgroundSize *v);
gpointer _gtk_css_value_get_boxed (const GtkCssValue *value);
const char ** _gtk_css_value_get_strv (const GtkCssValue *value);
GtkSymbolicColor *_gtk_css_value_get_symbolic_color (const GtkCssValue *value);
-GtkCssImage *_gtk_css_value_get_image (const GtkCssValue *value);
const GtkCssBackgroundSize *_gtk_css_value_get_background_size (const GtkCssValue *value);
const GtkCssBackgroundPosition *_gtk_css_value_get_background_position (const GtkCssValue *value);
const GtkCssBorderCornerRadius *_gtk_css_value_get_border_corner_radius (const GtkCssValue *value);
#include "config.h"
-#include "gtkcsstypesprivate.h"
#include "gtkthemingbackgroundprivate.h"
+
+#include "gtkcssimagevalueprivate.h"
+#include "gtkcsstypesprivate.h"
#include "gtkthemingengineprivate.h"
#include <math.h>
_gtk_theming_background_apply_clip (bg);
_gtk_theming_background_apply_origin (bg);
- bg->image = _gtk_css_value_get_image (_gtk_style_context_peek_property (bg->context, "background-image"));
+ bg->image = _gtk_css_image_value_get_image (_gtk_style_context_peek_property (bg->context, "background-image"));
}
void